/**
 *  @file
 *  @brief   空间几何点定义
 *  @author  wanghuan
 *  @date    2024.02.29
 *  @version  v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#ifndef Algebra_Point_h
#define Algebra_Point_h

//#pragma once
#include <vector>
// #include "DataStructure/Common/include/Out.h"
// #include "DataStructure/Common/include/Real.h"
#include "Matrix.h"
#include "Vector3D.h"

SG_NAMESPACE_OPEN
// SG_DATASTRUCTURE_NAMESPACE_OPEN
namespace Algebra
{
    /// @brief 3维空间点
    struct ALGEBRA_EXPORT Point
    {
        Point () = default;

        Point& Translate (Vector3D& off);

        /** @brief 将节点坐标转换到指定的坐标系下
         * @param [in] T, origin 坐标系基矢量构成的矩阵以及坐标原点
         * @param [in] p0        节点在局部坐标系下分量
         * @param [out] pNew     节点在世界坐标系下的分量
         */
        static void Transform (const Matrixd& T, const Point& origin, const Point& p0, _OUT Point& pNew);

        Real_t m_x = 0.0;  ///< x coordinate
        Real_t m_y = 0.0;  ///< y coordinate
        Real_t m_z = 0.0;  ///< z coordinate
    };

    using PointArray = std::vector<Point>;

    /// @brief 判断两个点是否相等
    ALGEBRA_EXPORT bool operator== (const Point& a, const Point& b);

    /// @brief 计算两个点之间的距离向量
    ALGEBRA_EXPORT Vector3D Distance (const Point& a, const Point& b);

    /// @brief 计算两个点之间长度
    ALGEBRA_EXPORT Real_t length (const Point& a, const Point& b);

    inline Point& Point::Translate (Vector3D& off)
    {
        this->m_x += off.m_x;
        this->m_y += off.m_y;
        this->m_z += off.m_z;
        return *this;
    }

};  // namespace Algebra

// SG_DATASTRUCTURE_NAMESPACE_CLOSE
SG_NAMESPACE_CLOSE

#endif  // Algebra_Point_h